//
//  HealthFilesViewController.m
//  1gene
//
//  Created by 1jiyin on 16/3/31.
//  Copyright © 2016年 1jiyin. All rights reserved.
//
//健康档案
#import "HealthFilesViewController.h"
#import "ZGWPeopleJianKangDangANModel.h"
#import "ZGWPeopleReportViewController.h"

#define kCurrentUserToken [[NSUserDefaults standardUserDefaults]objectForKey:@"token"]

@interface HealthFilesViewController ()<UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate>
@property(nonatomic,copy)UIButton *myBtn;
@property(nonatomic,copy)UIButton *othersBtn;
@property(nonatomic,copy)UITableView *myTableView;
@property(nonatomic,copy)NSMutableArray *dataArray;
@property(nonatomic,copy)UIAlertView *alertView;


/*
 *是否提示设置健康档案密码
 */
@property(nonatomic,assign)BOOL promptSetpassword;
/*
 *是否设置健康档案密码
 */
@property(nonatomic,assign)BOOL setpassword;
/*
 *健康档案密码
 */
@property(nonatomic,copy)NSString *passeord;

@property(nonatomic,copy)UIView *myView;


// 以下是张国文写的
@property (nonatomic, strong) UIScrollView *backGroundView;
@property (nonatomic, strong) UITableView *mineReportTableView; // 我的报告
@property (nonatomic, strong) UITableView *otherPeopleTableView; // 其他人的报告
@property (nonatomic, strong) NSMutableArray *mineJianKangArray; // 我的健康档案数组
@property (nonatomic, strong) NSMutableArray *otherJianKangArray; // 其他人的健康档案
@property (nonatomic, strong) NSTimer *myTimer; // 检查请求是否超时
@property (nonatomic, assign) NSInteger numberOfTime; // 存储请求时间


@end

@implementation HealthFilesViewController

- (void)viewWillDisappear:(BOOL)animated
{
    [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
    [self.myTimer invalidate];
    self.numberOfTime = 0;
    [super viewWillDisappear:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    [self createNavigation];
    _dataArray=[NSMutableArray array];
    [self initData];
    // 是否需要设置档案密码
    [self createUI];
 //   [self createUI2];
    
    // 张国文写的
    // 检查网络并请求数据
    [self searchNetAndAddData];
 
    // Do any additional setup after loading the view.
}
-(void)initData
{
    NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
    _promptSetpassword=[user boolForKey:@"promptSetHealthPassword"];
    _setpassword=[user boolForKey:@"sethealthPassword"];
    _passeord=[user objectForKey:@"healthPassword"];
}

#pragma mark - 检查网络并建立数据源
- (void)searchNetAndAddData
{
    if ([[[NetStatusHandle shareHandle] getNetStatus] isEqualToString:@"YES"]) {
        // 说明有网络
        // 建立数据源
        [self addData];
        
            // 说明不是示例报告
            // 建立计时器，计算是否超时
            self.myTimer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(goTimeOnMineJianKangDangAn:) userInfo:nil repeats:YES];
            [[NSRunLoop currentRunLoop] addTimer:self.myTimer forMode:NSRunLoopCommonModes];
            self.numberOfTime = 0;
            // 开始动画
            [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] startAnimation];
        
        
        
        
    } else {
        NSLog(@"没有网络");
        // 添加提示框
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"通知" Content:kNoNetNoRefresh ToView:self];
    }
}

#pragma mark - 添加数据源
- (void)addData
{
    // 所有采样人的url
    NSString *allCaiYangRenUrl = [NSString stringWithFormat:@"%@?token=%@", kZGWGetAllCaiYangRenMessage, kCurrentUserToken];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager GET:allCaiYangRenUrl parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        // 将计时器置为0
        self.numberOfTime = 0;
        [self.myTimer invalidate];
        // 结束动画
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
        if (!responseObject) {
            return;
        }
        NSArray *sample_usersArray = [responseObject valueForKey:@"sample_users"];
        // 我的
        self.mineJianKangArray = [NSMutableArray array];
        // 其他人
        self.otherJianKangArray = [NSMutableArray array];
        for (NSDictionary *tempDic in sample_usersArray) {
            if ([[tempDic valueForKey:@"relation"] isEqualToString:@"own"]) {
                ZGWPeopleJianKangDangANModel *zgwJianModel = [[ZGWPeopleJianKangDangANModel alloc] init];
                [zgwJianModel setValuesForKeysWithDictionary:tempDic];
                [self.mineJianKangArray addObject:zgwJianModel];
            } else {
                ZGWPeopleJianKangDangANModel *zgwJianModel = [[ZGWPeopleJianKangDangANModel alloc] init];
                [zgwJianModel setValuesForKeysWithDictionary:tempDic];
                [self.otherJianKangArray addObject:zgwJianModel];
            }
        }
        
        // 布局
        [self addMySubView];
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        // 关闭动画
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
        // 添加提示框
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"通知" Content:kHuoQuDataShiBaiNoRefresh ToView:self];
        // 暂停计时器
        [self.myTimer invalidate];
        self.numberOfTime = 0;
    }];
}

#pragma mark - 计时器方法
- (void)goTimeOnMineJianKangDangAn:(NSTimer *)timer
{
    self.numberOfTime++;
    NSLog(@"用户健康档案时间= %ld", self.numberOfTime);
    if (self.numberOfTime > kZGWQingQiuChaoShi) {
        NSLog(@"用户健康档案请求超时");
        self.numberOfTime = 0;
        [self.myTimer invalidate];
        // 关闭动画
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
        // 添加提示框
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"通知" Content:kQingQiuChaoShiNoReFresh ToView:self];
    }
}

#pragma mark - 根据结果提示用户
- (void)addAlertWithResultAndAlertString:(NSString *)alertString withOffset:(CGFloat)left
{
    UIView *tempView =[[UIView alloc]initWithFrame:CGRectMake(left, 0, self.view.frame.size.width, self.view.frame.size.height)];
    tempView.backgroundColor=[UIColor whiteColor];
    [self.backGroundView addSubview:tempView];
    
    
    UILabel *lab=[[UILabel alloc]init];
    lab.bounds=CGRectMake(0, 0, kScreenWidth, 30 * kAdjustParamater);
    lab.center=CGPointMake(self.view.center.x, self.view.center.y);
    lab.text=alertString;
    lab.font=[UIFont systemFontOfSize:18 * kAdjustParamater];
    lab.textColor=[UIColor blackColor];
    lab.textAlignment=NSTextAlignmentCenter;
    //lab.backgroundColor=[UIColor grayColor];
    [tempView addSubview:lab];
    
    //未收到消息图片
    UIImageView *imgView=[[UIImageView alloc]initWithFrame:CGRectMake((375 - 155) / 2 * kAdjustParamater, lab.frame.origin.y-155 * kAdjustParamater, 140 * kAdjustParamater, 155 * kAdjustParamater)];
    imgView.image=[UIImage imageNamed:@"receiveMessage_no"];
    [tempView addSubview:imgView];
}

#pragma mark - 布局
- (void)addMySubView
{
    self.backGroundView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    self.backGroundView.backgroundColor = [UIColor whiteColor];
    self.backGroundView.contentSize = CGSizeMake(kScreenWidth * 2, kScreenHeight);
    self.backGroundView.bounces = NO;
    self.backGroundView.pagingEnabled = YES;
    [self.view addSubview:_backGroundView];
    
    
    
    // 我的报告
    self.mineReportTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) style:UITableViewStylePlain];
    self.mineReportTableView.dataSource = self;
    self.mineReportTableView.delegate = self;
    self.mineReportTableView.backgroundColor = [UIColor whiteColor];
    self.mineReportTableView.tag = 200;
    self.mineReportTableView.showsVerticalScrollIndicator = NO;
    self.mineReportTableView.bounces = NO;
    self.mineReportTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.backGroundView addSubview:_mineReportTableView];
    
    // 其他人的报告
    self.otherPeopleTableView = [[UITableView alloc] initWithFrame:CGRectMake(kScreenWidth, 0, kScreenWidth, kScreenHeight) style:UITableViewStylePlain];
    self.otherPeopleTableView.dataSource = self;
    self.otherPeopleTableView.delegate = self;
    self.otherPeopleTableView.backgroundColor = [UIColor whiteColor];
    self.otherPeopleTableView.tag = 201;
    self.otherPeopleTableView.showsVerticalScrollIndicator = NO;
    self.otherPeopleTableView.bounces = NO;
    self.otherPeopleTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.backGroundView addSubview:_otherPeopleTableView];
    
    // 判断是否有数据，根据结果提示用户
    NSLog(@"我的：%ld, 他人的:%ld", self.mineJianKangArray.count, self.otherJianKangArray.count);
    if (self.mineJianKangArray.count == 0) {
        [self addAlertWithResultAndAlertString:@"您目前还没有健康档案呦!" withOffset:0];
    }
    if (self.otherJianKangArray.count == 0) {
        [self addAlertWithResultAndAlertString:@"您目前还没有添加其他采样人!" withOffset:kScreenWidth];
    }
    
}

-(void)createUI2
{
    _myView=[[UIView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height-64)];
    _myView.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:_myView];
    
    
    UILabel *lab=[[UILabel alloc]init];
    lab.bounds=CGRectMake(0, 0, 200, 30);
    lab.center=CGPointMake(self.view.center.x, self.view.center.y);
    lab.text=@"亲，你还没有健康档案哟!";
    lab.font=[UIFont systemFontOfSize:13];
    lab.textColor=[UIColor blackColor];
    lab.textAlignment=NSTextAlignmentCenter;
    //lab.backgroundColor=[UIColor grayColor];
    [_myView addSubview:lab];
    
    //未收到消息图片
    UIImageView *imgView=[[UIImageView alloc]initWithFrame:CGRectMake(lab.frame.origin.x+30, lab.frame.origin.y-155, 140, 155)];
    imgView.image=[UIImage imageNamed:@"receiveMessage_no"];
    [_myView addSubview:imgView];
    
}
-(void)createUI
{
//    _myTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
//    _myTableView.delegate=self;
//    _myTableView.dataSource=self;
//    _myTableView.tableFooterView=[UIView new];
//    _myTableView.tableHeaderView=[UIView new];
//    _myTableView.showsVerticalScrollIndicator=NO;
//    _myTableView.separatorStyle=UITableViewCellSeparatorStyleNone;
//    [self.view addSubview:_myTableView];

    
    if(_setpassword){
        // 需要设置健康档案
        _alertView=[[UIAlertView alloc]initWithTitle:@"请输入健康档案密码" message:nil delegate:self cancelButtonTitle:@"返回" otherButtonTitles:@"确定", nil];
        _alertView.alertViewStyle=UIAlertViewStyleSecureTextInput;
        UITextField *passwordTextField=[_alertView textFieldAtIndex:0];
        passwordTextField.placeholder=@"请输入密码";
        [_alertView show];
    }else{
        if (!_promptSetpassword) {
            _alertView=[[UIAlertView alloc]initWithTitle:@"是否设置健康档案密码" message:nil delegate:self cancelButtonTitle:@"否" otherButtonTitles:@"是", nil];
            _alertView.alertViewStyle=UIAlertViewStyleSecureTextInput;
            UITextField *passwordTextField=[_alertView textFieldAtIndex:0];
            passwordTextField.placeholder=@"请输入密码";
            [_alertView show];
        }
    }
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSLog(@"%ld",buttonIndex);
    if (!_promptSetpassword) {
        NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
        if (buttonIndex==0) {
            //取消
            [self.navigationController.view endEditing:YES];
            self.tabBarController.tabBar.hidden=NO;
            self.navigationController.navigationBar.hidden=YES;
            [self.navigationController popViewControllerAnimated:YES];
        }else{
            UITextField *passwordTextField=[alertView textFieldAtIndex:0];
            //确定
            
            if (passwordTextField.text.length==0) {
                _alertView=[[UIAlertView alloc]initWithTitle:@"是否设置健康档案密码" message:nil delegate:self cancelButtonTitle:@"否" otherButtonTitles:@"是", nil];
                _alertView.alertViewStyle=UIAlertViewStyleSecureTextInput;
                UITextField *passwordTextField=[_alertView textFieldAtIndex:0];
                passwordTextField.placeholder=@"请输入密码";
                [_alertView show];
            }else{
                //将密码存到本地
                [user setBool:YES forKey:@"sethealthPassword"];
                [user setObject:passwordTextField.text forKey:@"healthPassword"];
            }
        }

        [user setBool:YES forKey:@"promptSetHealthPassword"];
        [user synchronize];
    }else{
        UITextField *text=[alertView textFieldAtIndex:0];
        if (buttonIndex==0) {
            [self.navigationController.view endEditing:YES];
            self.tabBarController.tabBar.hidden=NO;
            self.navigationController.navigationBar.hidden=YES;
            [self.navigationController popViewControllerAnimated:YES];
        }else{
            if ([text.text isEqualToString:_passeord]) {

            }else{
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addTopGrayAlertNoImageWithContent:@"档案密码设置错误" toView:self];
                _alertView=[[UIAlertView alloc]initWithTitle:@"请输入健康档案密码" message:nil delegate:self cancelButtonTitle:@"返回" otherButtonTitles:@"确定", nil];
                _alertView.alertViewStyle=UIAlertViewStyleSecureTextInput;
                UITextField *passwordTextField=[_alertView textFieldAtIndex:0];
                passwordTextField.placeholder=@"请输入密码";
                [_alertView show];
            }
        }
        
    }
    
}
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    
}

#pragma mark - scorllview代理
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView.contentOffset.x == 0) {
        // 选中我的
        _othersBtn.backgroundColor=[UIColor colorWithRed:106/255.0 green:198/255.0 blue:223/255.0 alpha:1];
        [_othersBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _myBtn.backgroundColor=[UIColor whiteColor];
        [_myBtn setTitleColor:[UIColor colorWithRed:106/255.0 green:198/255.0 blue:223/255.0 alpha:1]forState:UIControlStateNormal];
    } else if (scrollView.contentOffset.x == kScreenWidth) {
        // 选中他人的
        _myBtn.backgroundColor=[UIColor colorWithRed:106/255.0 green:198/255.0 blue:223/255.0 alpha:1];
        [_myBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _othersBtn.backgroundColor=[UIColor whiteColor];
        [_othersBtn setTitleColor:[UIColor colorWithRed:106/255.0 green:198/255.0 blue:223/255.0 alpha:1]forState:UIControlStateNormal];
    }
}

#pragma mark - tableView的代理
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView.tag == 200) {
        return self.mineJianKangArray.count;
    }
    return self.otherJianKangArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag == 200) {
        // 说明是我的报告
        UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell"];
        if (cell==nil) {
            cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        UILabel *lab=[[UILabel alloc]initWithFrame:CGRectMake(10 * kAdjustParamater, 0, self.view.frame.size.width-10*2 * kAdjustParamater, 50 * kAdjustParamater)];
        if (self.mineJianKangArray.count > indexPath.row) {
            lab.text=@"我的健康报告";
        }
        lab.textColor=[UIColor blackColor];
        lab.textAlignment = NSTextAlignmentLeft;
        lab.font=[UIFont systemFontOfSize:15 * kAdjustParamater];
        [cell.contentView addSubview:lab];
        
        UIView *line=[[UIView alloc]initWithFrame:CGRectMake(0, 49 * kAdjustParamater, self.view.frame.size.width, 0.5 * kAdjustParamater)];
      //  line.backgroundColor=[UIColor colorWithRed:235/255.0 green:235/255.0 blue:241/255.0 alpha:1];
        line.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
        [cell.contentView addSubview:line];
        return cell;

    } else if (tableView.tag == 201) {
        // 说明是其他人的报告
        UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"othercell"];
        if (cell==nil) {
            cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        UILabel *lab=[[UILabel alloc]initWithFrame:CGRectMake(10 * kAdjustParamater, 0, self.view.frame.size.width-10*2 * kAdjustParamater, 50 * kAdjustParamater)];
        if (self.otherJianKangArray.count > indexPath.row) {
            ZGWPeopleJianKangDangANModel *model = self.otherJianKangArray[indexPath.row];
            lab.text= [NSString stringWithFormat:@"%@的健康档案", model.name];
        }
        
        lab.textColor=[UIColor blackColor];
        lab.textAlignment = NSTextAlignmentLeft;
        lab.font=[UIFont systemFontOfSize:15 * kAdjustParamater];
        [cell.contentView addSubview:lab];
        
        UIView *line=[[UIView alloc]initWithFrame:CGRectMake(0, 49 * kAdjustParamater, self.view.frame.size.width, 0.5 * kAdjustParamater)];
        //  line.backgroundColor=[UIColor colorWithRed:235/255.0 green:235/255.0 blue:241/255.0 alpha:1];
        line.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
        [cell.contentView addSubview:line];
        return cell;
    }
    return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50 * kAdjustParamater;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag == 200) {
        // 我的
        ZGWPeopleReportViewController *zgwPeopleReportVC = [[ZGWPeopleReportViewController alloc] init];
        zgwPeopleReportVC.isMine = YES;
        if (self.mineJianKangArray.count > indexPath.row) {
            ZGWPeopleJianKangDangANModel *model = self.mineJianKangArray[indexPath.row];
            zgwPeopleReportVC.sampleuser_id = model.sampleuser_id;
            zgwPeopleReportVC.sampleUserName = model.name;
            zgwPeopleReportVC.isMine = YES;
        }
        [self.navigationController pushViewController:zgwPeopleReportVC animated:YES];
    } else if (tableView.tag == 201) {
        // 他人的
        ZGWPeopleReportViewController *zgwPeopleReportVC = [[ZGWPeopleReportViewController alloc] init];
        zgwPeopleReportVC.isMine = NO;
        if (self.otherJianKangArray.count > indexPath.row) {
            ZGWPeopleJianKangDangANModel *model = self.otherJianKangArray[indexPath.row];
            zgwPeopleReportVC.sampleuser_id = model.sampleuser_id;
            zgwPeopleReportVC.sampleUserName = model.name;
            zgwPeopleReportVC.isMine = NO;
        }
        [self.navigationController pushViewController:zgwPeopleReportVC animated:YES];
    }
}

// 构建导航栏
-(void)createNavigation
{
    [self.navigationController.navigationBar setTranslucent:NO];
    self.navigationController.navigationBar.hidden=NO;
    self.navigationController.navigationBar.barTintColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    //返回
    UIButton *leftBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame=CGRectMake(0, 0, 25, 25);
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"left_back"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    
    UIView *titleView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 150, 30)];
    
    //我的
    UIButton *myBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    myBtn.frame=CGRectMake(0, 0, 75, 30);
    myBtn.titleLabel.font=[UIFont systemFontOfSize:15];
    myBtn.backgroundColor=[UIColor whiteColor];
    [myBtn setTitle:@"我的" forState:UIControlStateNormal];
    [myBtn setTitleColor:[UIColor colorWithRed:106/255.0 green:198/255.0 blue:223/255.0 alpha:1] forState:UIControlStateNormal];
    [myBtn addTarget:self action:@selector(myBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [titleView addSubview:myBtn];
    
    
    //他人的
    UIButton *othersBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    othersBtn.frame=CGRectMake(75, 0, 75, 30);
    othersBtn.titleLabel.font=[UIFont systemFontOfSize:15];
    othersBtn.backgroundColor=[UIColor colorWithRed:106/255.0 green:198/255.0 blue:223/255.0 alpha:1];
    [othersBtn setTitle:@"他人的" forState:UIControlStateNormal];
    [othersBtn setTitleColor:[UIColor whiteColor]
                    forState:UIControlStateNormal];
    [othersBtn addTarget:self action:@selector(othersBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [titleView addSubview:othersBtn];
    _myBtn=myBtn;
    _othersBtn=othersBtn;
//    //标题
//    UILabel *title=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];
//    title.text=@"";
//    title.font=[UIFont systemFontOfSize:22];
//    title.textAlignment=NSTextAlignmentCenter;
//    title.textColor=[UIColor whiteColor];
    self.navigationItem.titleView=titleView;
}

// 他人的
-(void)othersBtnClick:(UIButton *)sender
{
    _myBtn.backgroundColor=[UIColor colorWithRed:106/255.0 green:198/255.0 blue:223/255.0 alpha:1];
    [_myBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _othersBtn.backgroundColor=[UIColor whiteColor];
    [_othersBtn setTitleColor:[UIColor colorWithRed:106/255.0 green:198/255.0 blue:223/255.0 alpha:1]forState:UIControlStateNormal];
    // 改变contentoff
    self.backGroundView.contentOffset = CGPointMake(kScreenWidth, 0);
}

// 我的
-(void)myBtnClick:(UIButton *)sender
{
    _othersBtn.backgroundColor=[UIColor colorWithRed:106/255.0 green:198/255.0 blue:223/255.0 alpha:1];
    [_othersBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _myBtn.backgroundColor=[UIColor whiteColor];
    [_myBtn setTitleColor:[UIColor colorWithRed:106/255.0 green:198/255.0 blue:223/255.0 alpha:1]forState:UIControlStateNormal];
    // 改变contentoff
    self.backGroundView.contentOffset = CGPointMake(0, 0);
}
//返回上一页
-(void)leftBtnClick:(UIButton *)sender
{
    self.tabBarController.tabBar.hidden=NO;
    self.navigationController.navigationBar.hidden=YES;
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


//设置健康档案密码
-(void)setHealthPassword
{
    AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
    manager.requestSerializer=[AFHTTPRequestSerializer serializer];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
  //  NSString *token=[user objectForKey:@"token"];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
